/**
 * 存储方法
 * 注:所有方法无需导入即可使用
 */

// 设置缓存
export const setStorage = (key = "", val = null) => {
   localStorage.setItem(key, val)
}

// 获取缓存
export const getStorage = (key = "") => {
   return localStorage.getItem(key)
}

// 设置JSON缓存
export const setJSONStorage = (key = "", val = null) => {
   setStorage(key, JSON.stringify(val))
}

// 获取JSON缓存
export const getJSONStorage = (key = "") => {
   return JSON.parse(getStorage(key))
}

// 移除缓存
export const removeStorage = (key = "") => {
   localStorage.removeItem(key)
}

// 清空缓存
export const clearStorage = () => {
   localStorage.clear()
}
